//
//  EXT+UIImageView.swift
//  新浪微博
//
//  Created by 季伯文 on 2017/6/29.
//  Copyright © 2017年 bowen. All rights reserved.
//

import UIKit
import SDWebImage

extension UIImageView {
    //实例化一个imageview
    convenience init(named: String) {
        self.init(image: UIImage(named: named))
    }
    
    //封装sd
    func jbw_setImage(withUrlString: String?, placeholderImgName: String? = nil){
        
        if placeholderImgName == nil {
            self.sd_setImage(with: URL(string: withUrlString ?? ""), placeholderImage: self.image)
//            self.sd_setImage(with: URL(string: withUrlString ?? ""), placeholderImgName:self.image)
        } else {
            self.sd_setImage(with: URL(string: withUrlString ?? ""), placeholderImage: UIImage(named: placeholderImgName ?? ""))
//            self.sd_setImage(with: URL(string: withUrlString ?? ""), placeholderImgName:UIImage(named:placeholderImgName ?? ""))
        }
        
    }
}
